//
//  HomeViewController.m
//  Weibo
//
//  Created by student on 16/4/21.
//  Copyright © 2016年 BulidFuture. All rights reserved.
//

#import "HomeViewController.h"
#import "VisitorView.h"
#import "UIBarButtonItem+Create.h"
#import "TitleButton.h"
@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (!self.userLogin) {
        [self.visitorView setupVisitorInfo:YES iamgeName:@"visitordiscover_feed_image_house" message:@"关注一些人，看看有什么惊喜"];
    }
    //设置导航栏上的按钮
    [self setupNavi];
    
}
-(void)setupNavi
{
    // 1. 添加左右的按钮
    //    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    //    [btn setImage:[UIImage imageNamed:@"navigationbar_friendattention"] forState:UIControlStateNormal];
    //    [btn setImage:[UIImage imageNamed:@"navigationbar_friendattention_highlighted"] forState:UIControlStateHighlighted];
    //    [btn addTarget:self action:@selector(leftItemPressed:) forControlEvents:UIControlEventTouchUpInside];
    //    [btn sizeToFit];
    //    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.navigationItem.leftBarButtonItem=[UIBarButtonItem cteateBarButtonItem:@"navigationbar_friendattention" target:self action:@selector(leftItemPressed:)];
     self.navigationItem.rightBarButtonItem=[UIBarButtonItem cteateBarButtonItem:@"navigationbar_pop" target:self action:@selector(rightItemPressed:)];
    
    //2.创建标题按钮
    TitleButton *titleBtn=[[TitleButton alloc]init];
    [titleBtn setTitle:@"chen" forState:UIControlStateNormal];
    
    [titleBtn addTarget: self action:@selector(titleBtnPressed:) forControlEvents:UIControlEventTouchUpInside];
    [titleBtn addTarget:self action:@selector(titleBtnPressed:) forControlEvents:UIControlEventTouchUpInside];
    [titleBtn sizeToFit];
    self.navigationItem.titleView = titleBtn;

    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)leftItemPressed:(id)sender
{
    NSLog(@"%s",__func__);
}
-(void)rightItemPressed:(id)sender
{
    NSLog(@"%s",__func__);
}
- (void)titleBtnPressed:(UIButton *)sender
{
    NSLog(@"%s",__func__);
    sender.selected = !sender.selected;
}


@end
